package com.cgg.designpatterns.iterator;

import java.util.Iterator;

/**
 * @author Xiecheng create on 2021/7/2
 */
public class Main {
    public static void main(String[] args) {
        BookShelf shelf = new BookShelf(6);
        shelf.append(new Book("三国演义"));
        shelf.append(new Book("水浒传"));
        shelf.append(new Book("红楼梦"));
        shelf.append(new Book("西游记"));
        shelf.append(new Book("论语"));
        shelf.append(new Book("金瓶梅"));

        Iterator<Book> iterator = shelf.iterator();
        while (iterator.hasNext()) {
            System.out.println("current book is:" + iterator.next().getName());
        }
    }
}
